package com.tanhua.dubbo.server.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanhua.common.mapper.UserMapper;
import com.tanhua.common.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;


@Service
public class UserService {
    @Autowired
    private RestTemplate restTemplate;

    @Autowired
    private UserMapper userMapper;

    /**
     * @description  请求token解析
     * @param token
     * @updateTime 2021/12/28 23:43
     * @return: com.tanhua.common.pojo.User
     */
    public User queryToken(String token) {
        //发送get请求,请求sso的token校验服务,返回user对象
        try {
            //捕获sso系统请求异常,更好的知道了token是解析失败
            User user = restTemplate.getForObject("http://127.0.0.1/user/" + token, User.class);
            return user;
        } catch (Exception ex) {
            return null;
        }
    }

}
